﻿Imports Microsoft.Crm.Workflow

<CrmWorkflowActivity("toIDN", "String Utilities")> _
Public Class toIDN
    Inherits SequenceActivity
    Public Shared PunycodeInputProperty As DependencyProperty = DependencyProperty.Register("PunycodeInput", GetType(String), GetType(toIDN))
    <CrmInput("Punycode")> _
    Public Property PunycodeInput() As [String]
        Get
            Return DirectCast(MyBase.GetValue(PunycodeInputProperty), [String])
        End Get
        Set(ByVal value As [String])
            MyBase.SetValue(PunycodeInputProperty, value)
        End Set
    End Property

    Public Shared IDNOutputProperty As DependencyProperty = DependencyProperty.Register("IDNOutput", GetType(String), GetType(toIDN))
    <CrmOutput("IDN")> _
    Public Property IDNOutput() As [String]
        Get
            Return DirectCast(MyBase.GetValue(IDNOutputProperty), [String])
        End Get
        Set(ByVal value As [String])
            MyBase.SetValue(IDNOutputProperty, value)
        End Set
    End Property
    Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus
        Dim IDNmapping As New System.Globalization.IdnMapping
        IDNOutput = IDNmapping.GetAscii(PunycodeInput)
        Return MyBase.Execute(executionContext)
    End Function
End Class